<?php
class modimagecontent extends CI_Model{
	var $image = "images_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_image,$type_image,$image_content,$deskripsi_gambar)
	{
		$this->id_image= $id_image;
		$this->type_image= $type_image;
		$this->image_content= $image_content;
		$this->deskripsi_gambar= $deskripsi_gambar;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->image, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{		
		$arrayData = array(
			'id_image'=>$this->id_image,
			'type_image'=>$this->type_image,
			'image_content'=>$this->image_content,
			'deskripsi_gambar'=>$this->deskripsi_gambar
		);
		return $this->db->insert($this->image, $arrayData);
	}
	
	function update($id_image)
	{
		$arrayData = array(
			'type_image'=>$this->type_image,
			'image_content'=>$this->image_content,
			'deskripsi_gambar'=>$this->deskripsi_gambar
		);
		$this->db->where('id_image', $id_image);
		return $this->db->update($this->image, $arrayData);
	}
        
	function remove($id_image)
	{
		$this->db->where('id_image', $id_image);
		return $this->db->delete($this->image);
	}	
	
	function detail($id_image)
	{
		$this->db->where('id_image', $id_image);
		$query = $this->db->get($this->image);	
		return $query->result_array();
	}
	
	function getImageContent($type_image)
	{
		$this->db->where('type_image', $type_image);
		$query = $this->db->get($this->image);	
		return $query->result_array();
	}
}
?>